import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  { // 登录的路由
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  { // tabbar父路由
    path: '/',
    name: 'layout',
    component: () => import('@/views/layout'),
    // 子路由
    children: [
      {
        path: '',
        name: 'home',
        component: () => import('@/views/home')
      },
      {
        path: '/qa',
        name: 'qa',
        component: () => import('@/views/qa')
      },
      {
        path: '/video',
        name: 'video',
        component: () => import('@/views/video')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('@/views/my')
      }
    ]
  },
  { // 搜索页面路由
    path: '/search',
    name: 'search',
    component: () => import('@/views/search')
  },
  { // 文章列表详情页面路由
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/article'),
    // 开启了props传参articleId  ArticleIndex组件中   赋值给了articleId
    props: true
  },
  // 用户个人资料
  { // 文章列表详情页面路由
    path: '/user/profile',
    name: 'user-profile',
    component: () => import('@/views/user-profile'),
    // 开启了props传参articleId  ArticleIndex组件中   赋值给了articleId
    props: true
  }
]

const router = new VueRouter({
  routes
})

export default router
